<?php

include_once 'CodeObject.php';
include_once 'CommentStatementCollection.php';
include_once 'Statement.php';
include_once 'StatementCollection.php';
include_once 'TypeDeclarationCollection.php';

class CodeNamespace extends CodeObject
{
    public function __construct(
        $name = null, TypeDeclarationCollection $Types = null,
        StatementCollection $Statements = null,
        CommentStatementCollection $Comments = null)
    {
        $this->set_Name($name);

        is_null($Types) ?
            $this->Types = new TypeDeclarationCollection() :
            $this->set_Types($Types);
        
        is_null($Statements) ?
            $this->Statements = new StatementCollection :
            $this->set_Statements($Statements);
        
        is_null($Comments) ?
            $this->Comments = new CommentStatementCollection() :
            $this->set_Comments($Comments);
    }
    
    public function __set($name, $value)
    {
        parent::__set($name, $value);
        
        if($name == 'Name')
        {
            $this->set_Name($value);
        }
        
        if($name == 'Statements')
        {
            $this->set_Statements($value);
        }
        
        if($name == 'Types')
        {
            $this->set_Types($value);
        }
    }
    
    public function __get($name)
    {
        $ret = parent::__get($name);
        
        if($ret != null)
        {
            return $ret;
        }
        
        if($name == 'Name')
        {
            return $this->get_Name();
        }
        
        if($name == 'Statements')
        {
            return $this->get_Statements();
        }
        
        if($name == 'Types')
        {
            return $this->get_Types();
        }
    }
    
    public function get_Name()
    {
        return $this->Name;
    }

    public function set_Name($Name)
    {
        if(is_string($Name) || is_null($Name))
        {
            $this->Name = $Name;
        }
        else
        {
            throw new InvalidArgumentException(
                'The namespace name should be a string or a null value.');
        }
    }

    public function get_Statements()
    {
        return $this->Statements;
    }

    public function set_Statements(StatementCollection $Statements)
    {
        $this->Statements = $Statements;
    }

    public function get_Types()
    {
        return $this->Types;
    }

    public function set_Types(TypeDeclarationCollection $Types)
    {
        $this->Types = $Types;
    }

    private $Name;
    private $Types;
    private $Statements;
}

?>
